﻿namespace LogManager.Core.Models.Smtp
{
    using LogManager.Utils.ChangeTracking;
    using System.Net.Mail;

    public class Email : PropertyChangeBase
    {
        private MailAddress _value;

        public MailAddress Value
        {
            get { return _value; }
            set
            {
                _value = value;
                RaisePropertyChanged(() => Value);
            }
        }

        public Email()
        {
        }

        public Email(MailAddress value)
        {
            this.Value = value;
        }

        public static implicit operator Email(MailAddress mail)
        {
            if (mail == null) return null;
            return new Email(mail);
        }

        public static implicit operator MailAddress(Email email)
        {
            if (email == null) return null;
            return email.Value;
        }
    }
}
